package com.hkbigdata.sybx.mapper;

/**
 * @author liuanbo
 * @creat 2025-05-29-18:21
 * @see 2194550857@qq.com
 */

import com.hkbigdata.sybx.bean.UserFeedback;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserFeedbackMapper {
    @Insert("insert into user_feedback (user_id, problem_types,problem_description,contact_information) " +
            "values (#{userId}, #{problemTypes}, #{problemDescription}, #{contactInformation})")
    int insertUserFeedback(UserFeedback userfeedback);
    /** 删除用户反馈(根据用户ID) */
    @Delete("DELETE FROM user_feedback WHERE user_id = #{userId}")
    int deleteUserFeedbackByUserId(String userId);

    /** 更新用户反馈 */
    @Update("UPDATE user_feedback SET " +
            "problem_types = #{problemTypes}, " +
            "problem_description = #{problemDescription}, " +
            "contact_information = #{contactInformation} " +
            "WHERE user_id = #{userId}")
    int updateUserFeedback(UserFeedback userFeedback);

    /** 根据用户ID查询反馈 */
    @Select("SELECT problem_types as problemTypes, problem_description as problemDescription, contact_information as contactInformation FROM user_feedback WHERE user_id = #{userId}")
    List<UserFeedback> selectUserFeedbackByUserId(String userId);

    /** 查询所有反馈 */
    @Select("SELECT problem_types as problemTypes, problem_description as problemDescription, contact_information as contactInformation, user_id as userId FROM user_feedback")
    List<UserFeedback> selectAllUserFeedback();
}
